﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using HotelManagement._04.OBJECT;
using HotelManagement._03.DAO;

namespace HotelManagement._02.BUS
{
    class CheckOutBUS
    {
        CheckOutDAO m_CheckOutDAO = new CheckOutDAO();

        public DataTable ViewCheckOut()
        {
            return m_CheckOutDAO.ViewCheckIn("pr_tblCheckIn_ViewCheckOut");
        }

        public DataTable ViewInfoCustomer(int ip_CustomerID)
        {
            return m_CheckOutDAO.ViewInfoCustomer(ip_CustomerID, "pr_tblCustomer_SelectRow_ByCheckInID");
        }

        public DataTable SelectRoomID()
        {
            return m_CheckOutDAO.ViewCheckIn("pr_tblRoom_SelectRoomID");
        }

        public DataTable ViewSearchByCustomerName(string ip_CustomerName)
        {
            return m_CheckOutDAO.ViewSearchByCustomerName(ip_CustomerName, "pr_tblCheckIn_ViewCheckOutSearch");
        }

        public DataTable GetCostByRoomID(string ip_RoomID)
        {
            return m_CheckOutDAO.GetCostByRoomID(ip_RoomID, "pr_tblRoomType_GetCostByRoomID");
        }

        public bool CheckOut(CheckOut ip_CheckOut)
        {
            if(m_CheckOutDAO.UpdateCheckOut(ip_CheckOut,"pr_tblCheckIn_CheckOutUpdate"))
            {
                if (m_CheckOutDAO.UpdateRoom(ip_CheckOut, "pr_tblRoom_CheckOutUpdate"))
                {
                    return true;
                }
                return false;
            }
            return false;
        }
    }
}
